<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/jsp/inc/header.jsp" %>
<c:set var="title" value="区块"/>
<c:set var="rootpath" value="${CONTEXT_PATH}/admin/site/region/"/>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="${STATIC_HOST}/css/ligerui.css" rel="stylesheet" type="text/css"/>
    <link href="${STATIC_HOST}/css/common.css" rel="stylesheet" type="text/css" />
    <script src="${STATIC_HOST}/js/common.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/LG.js" type="text/javascript"></script>
    <title>${title}管理</title>
</head>
<body>
<form:form commandName="region" class="l-form" id="mainform" name="mainform" method="post" action="${rootpath}/save.do">
  <div class="l-group l-group-hasicon"><img src="${STATIC_HOST}/images/common/communication.gif"><span>当前位置: 宇宙CMS &gt; <a href="${rootpath}/list.do">${title}管理</a> &gt; ${region.id==0 ? '新增' : '修改'}${title}</span></div>
    <div id="errorLabelContainer"> <form:errors path="*"/></div>
        <input type="hidden" name="queryParam" value="${queryParam}"/>
		<input type="hidden" name="id" id="id" value="${region.id}"/>
		
      <ul>
      <li class="li_show_left" style="padding-left:30px;"><label for="siteId">站点ID</label> <span style="color:red">*</span>:</li>
           <li class="li_show_right">
               <input type="text" name="siteId" id="siteId" size="10" ltype='text' ligerui='{"width":150}'  value="${region.siteId}"/>
               <input value="..." type="button" class="l-button ellipsis"  onclick="f_select({'targetId':'siteId','selectType':'/admin/site/site'})">
           <span class='formValidatorError'><form:errors path="siteId" /></span>
      </li>
      </ul><!--换行-->
      <ul>
      <li class="li_show_left" style="padding-left:30px;"><label for="name">区块名称</label> <span style="color:red">*</span>:</li>
           <li class="li_show_right">
        <input type="text" name="name" id="name" size="60" maxlength="100" ltype='text'  validate="{required:true,minlength:0,maxlength:100}" value="${region.name}"/>
       <span class='formValidatorError'><form:errors path="name" /></span>
      </li>
      </ul><!--换行-->
      <ul>
      <li class="li_show_left" style="padding-left:30px;"><label for="type">区块类型</label> <span style="color:red">*</span>:</li>
        <li class="li_show_right">
           <select name="type" id="type" ltype="select" size="1" >
               <c:forEach var="obj" items="${regionTypeMap}" varStatus="idx">
                   <option value="${obj.key}" <c:if test="${region.type==obj.key}">selected</c:if>>${obj.value}</option>
               </c:forEach>
           </select>
        </li>
      </ul><!--换行-->
      <ul id="style_templateIdList" <c:if test="${region.type=='1'}">style="display: none;"</c:if>>
      <li class="li_show_left" style="padding-left:30px;"><label for="templateIdList">模板IDS</label> <span style="color:red">*</span>:</li>
           <li class="li_show_right">
               <input type="text" name="templateIdList" id="templateIdList" size="10" ltype='text' ligerui='{"width":150}'  value="${region.templateIdList}"/>
               <input value="..." type="button" class="l-button ellipsis"  onclick="f_select({'targetId':'templateIdList','gridMultiple':'1','selectType':'/admin/template/template','callback':'writeTemplateIdList'})">
           <span class='formValidatorError'><form:errors path="templateIdList" /></span>
      </li>
      </ul><!--换行-->
      <ul>
          <li class="li_show_left" style="padding-left:30px;"><label for="status">状  态</label> <span style="color:red">*</span>:</li>
          <li class="li_show_right">
              <select name="status" id="status" ltype="select" size="1" >
                  <c:forEach var="obj" items="${statusMap}" varStatus="idx">
                      <option value="${obj.key}" <c:if test="${region.status==obj.key}">selected</c:if>>${obj.value}</option>
                  </c:forEach>
              </select>
          </li>
      </ul><!--换行-->
      <ul>
        <li class="li_show_left" style="padding-left:30px;"><label for="memo">备  注</label> <span style="color:red">*</span>:</li>
        <li class="li_show_right">
            <textarea name="memo" id="memo" rows="3" cols="80" class="l-textarea" validate="{minlength:0,maxlength:420}">${region.memo}</textarea>
            <span class='formValidatorError'><form:errors path="memo" /></span>
        </li>
      </ul><!--换行-->

  <div class="l-group l-group-hasicon"></div> 
  <input type="submit" value="提交" id="mainformsubmit" class="l-button l-button-submit form_submit_button"/> 
  <c:if test="${fn:contains(header.referer,rootpath)}"><input type="button" value="返回" class="l-button l-button-test" style="float:left;" onClick="location.href='${header.referer}'" /></c:if>
</form:form>
<script type="text/javascript" >
var mainform = $("#mainform");
mainform.ligerForm();

$(document).ready(function(){
    $('#type').change(function(){
        var type = $('#type').val();
        if( type == 1){
            $('#style_templateIdList').hide();
        }
        if( type == 2){
            $('#style_templateIdList').show();
        }
    });
});

    function writeTemplateIdList(jsonData) {
        var result= eval('(' + jsonData + ')');
        idString= result[0].id;
        for(var i=1; i< result.length; i++){
            idString = idString+','+result[i].id;
        }
        var templateIdList= jQuery("#templateIdList").val();
        if(templateIdList != ""){
            idString= templateIdList +',' +idString;
        }
        jQuery("#templateIdList").val(idString);
    }
</script>
<div id="scrolltop">返回顶部</div>
<%@ include file="/jsp/inc/footer.jsp"%>
</body>
</html>